package com.chenglai.goods.dao;

import com.chenglai.goods.pojo.ProductAnswer;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author jiang
 * @created 2023/11/16 10:07:23
 **/

@Repository
public interface ProductAnswerMapper extends Mapper<ProductAnswer> {

    @Select("<script>"+
            "SELECT a.*,b.user_name  " +
            "FROM t_cl_productAnswer a  " +
            "LEFT JOIN t_cl_user b  " +
            "ON a.user_id = b.user_id  " +
            "<if test='flag == 0'>WHERE a.product_id = #{Id} </if> "+
            "<if test='flag == 1'>WHERE a.parent_id = #{Id} </if> "+
            "<if test='flag == 2'>WHERE a.shop_id = #{Id} </if> "+
            "</script>")
    List<ProductAnswer> getAnswerComment(@Param("Id") Integer Id, Integer flag);

}
